package com.zhongke.DKYCboot.controller;


import com.zhongke.DKYCboot.service.BaseCustomerService;
import com.zhongke.DKYCboot.service.impl.BaseCustomerServiceimpl;
import com.zhongke.DKYCboot.util.Msg;
import com.zhongke.DKYCboot.util.Result;
import com.zhongke.DKYCboot.vo.BaseCustomerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@CrossOrigin
@RequestMapping("/BaseCustomer")
public class BaseCustomerController {

    @Autowired
    private BaseCustomerService baseCustomerService;

    /**
     * 查看用户详情
     * @param id
     * @return
     */
    @RequestMapping(value = "/selectBaseById" ,method = RequestMethod.POST)
    @ResponseBody
    public Msg selectBaseById(int id) {
        return baseCustomerService.selectBaseById(id);

    }

    /**
     * 新增用户
     * @param request
     * @return
     */
    @RequestMapping(value = "/insertBaseUser",method = RequestMethod.POST)
    @ResponseBody
    public Msg insertBaseUser(HttpServletRequest request) {
        return baseCustomerService.insertBaseUser(request);
    }

    /**
     * 修改用户信息
     * @param request
     * @return
     */
    @RequestMapping(value = "/updateBaseUser" ,method = RequestMethod.POST)
    @ResponseBody
    public Msg updateBaseUser(HttpServletRequest request) {
        return baseCustomerService.updateBaseUser(request);
    }

    /**
     * 删除用户信息
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteBaseUser" ,method = RequestMethod.POST)
    @ResponseBody
    public Msg deleteBaseUser(int id) {
        return baseCustomerService.deleteBaseUser(id);
    }

    /**
     * 模糊查询列表
     * @param baseCustomer
     * @return
     */
    @RequestMapping(value = "/findAll",method = RequestMethod.POST)
    @ResponseBody
    public Msg findAll(BaseCustomerVo baseCustomer) {
        return baseCustomerService.findAll(baseCustomer);
    }

    /**
     * 登录
     * @param tel
     * @param password
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public Msg login(String tel, String password) {
        return baseCustomerService.login(tel, password);
    }
}
